import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SaleContractVO, SaleContractForm, SaleContractQuery } from '@/api/finance/saleContract/types';

/**
 * 查询销售合同列表
 * @param query
 * @returns {*}
 */

export const listSaleContract = (query?: SaleContractQuery): AxiosPromise<SaleContractVO[]> => {
  return request({
    url: '/finance/saleContract/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询销售合同详细
 * @param id
 */
export const getSaleContract = (id: string | number): AxiosPromise<SaleContractVO> => {
  return request({
    url: '/finance/saleContract/' + id,
    method: 'get'
  });
};

/**
 * 新增销售合同
 * @param data
 */
export const addSaleContract = (data: SaleContractForm) => {
  return request({
    url: '/finance/saleContract',
    method: 'post',
    data: data
  });
};

/**
 * 修改销售合同
 * @param data
 */
export const updateSaleContract = (data: SaleContractForm) => {
  return request({
    url: '/finance/saleContract',
    method: 'put',
    data: data
  });
};

/**
 * 删除销售合同
 * @param id
 */
export const delSaleContract = (id: string | number | Array<string | number>) => {
  return request({
    url: '/finance/saleContract/' + id,
    method: 'delete'
  });
};
